Note
This is a script command and operates only in scripts when scripting is enabled with the following command: enable cli scripting {permanent}.Optionally executes a code block based on the condition supplied.
expression | Specifies the condition for which the statements should be executed. |
statements | Actions to be executed when the specified conditions are met. |
N/A.
This command is usually followed by statements that are executed if the condition evaluates to true.
It can also be followed by an ELSE block, which is executed if the condition evaluates to false.
The IF construct should be terminated by an ENDIF command.
The _expression must be enclosed in parentheses.
The IF construct can be nested inside other IF and WHILE constructs. Nesting is supported up to five levels. If there is incorrect nesting of IF conditions, an error message is displayed. If a user tries to execute more than five nested IF conditions, an error message is displayed.
The operators mentioned in Using Operators can be used in an _expression in an IF condition.
You can insert comments by using a number sign (#).
The following example executes the show switch command if the value of the variable is greater than 2 and executes the show vlan command otherwise:
IF ($x > 2) THEN show switch ELSE show vlan ENDIF
This command was first available in ExtremeXOS 11.6.
This command is available on all Universal switches supported in this document.